﻿using System;
using GeoAPI.Geometries;
using NetTopologySuite.Geometries;

namespace NetTopologySuite.Triangulate
{
	public class Segment
	{
		public Segment(double x1, double y1, double z1, double x2, double y2, double z2) : this(new Coordinate(x1, y1, z1), new Coordinate(x2, y2, z2))
		{
		}

		public Segment(double x1, double y1, double z1, double x2, double y2, double z2, object data) : this(new Coordinate(x1, y1, z1), new Coordinate(x2, y2, z2), data)
		{
		}

		public Segment(Coordinate p0, Coordinate p1, object data)
		{
			this._ls = new LineSegment(p0, p1);
			this.Data = data;
		}

		public Segment(Coordinate p0, Coordinate p1)
		{
			this._ls = new LineSegment(p0, p1);
		}

		public Coordinate Start
		{
			get
			{
				return this._ls.GetCoordinate(0);
			}
		}

		public Coordinate End
		{
			get
			{
				return this._ls.GetCoordinate(1);
			}
		}

		public double StartX
		{
			get
			{
				return this._ls.GetCoordinate(0).X;
			}
		}

		public double StartY
		{
			get
			{
				return this._ls.GetCoordinate(0).Y;
			}
		}

		public double StartZ
		{
			get
			{
				return this._ls.GetCoordinate(0).Z;
			}
		}

		public double EndX
		{
			get
			{
				return this._ls.GetCoordinate(1).X;
			}
		}

		public double EndY
		{
			get
			{
				return this._ls.GetCoordinate(1).Y;
			}
		}

		public double EndZ
		{
			get
			{
				return this._ls.GetCoordinate(1).Z;
			}
		}

		public LineSegment LineSegment
		{
			get
			{
				return this._ls;
			}
		}

		public object Data { get; set; }

		public bool EqualsTopologically(Segment s)
		{
			return this._ls.EqualsTopologically(s.LineSegment);
		}

		public Coordinate Intersection(Segment s)
		{
			return this._ls.Intersection(s.LineSegment);
		}

		public override string ToString()
		{
			return this._ls.ToString();
		}

		private readonly LineSegment _ls;
	}
}
